<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
	
	 
	function fullURL(){
		$ci=& get_instance();
		$query = $_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '';
		return $ci->config->site_url().$ci->uri->uri_string(). $query;  
	}
	
	function baseURL(){
		$ci=& get_instance();
		return $ci->config->site_url().$ci->uri->uri_string();
	}
	
	function php2js(){
		$json = !empty($_GET) ? json_encode($_GET) : '{}';
		return "
			<script type='text/javascript'>
				var __GET = $json;
				var __URL = '".fullURL()."';
				var __BASE_URL = '".baseURL()."';
				
				function _toURLstring(){
					return jQuery.param(__GET);
				}
				
				function _buildNewString(){
					return __BASE_URL+'/?'+_toURLstring();
				}
				
				function _makeQueryURL(){
					window.location = _buildNewString();
				}
			</script>
		";
	}
/***	
	if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
		 
	}else{
		php2js();
	}
***/	
?>
